package com.boot.dog.web.security.handler;

import com.boot.dog.web.security.util.SecurityResult;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.web.access.AccessDeniedHandler;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @Author: MaxLv
 * @Date: 2019/12/2
 */
@Component
public class MyAccessDeniedHandler implements AccessDeniedHandler {

    @Override
    public void handle(HttpServletRequest request, HttpServletResponse response,
                       AccessDeniedException accessDeniedException) {
        SecurityResult.forbidden(response, "抱歉，您没有操作权限!");
    }

}
